using System;

using Atomic.Libraries.Mathematics;

namespace Atomic.Structures.Symmetries
{
	[Serializable]
	public class SpaceGroupSymmetryOperation
	{
		public SpaceGroupSymmetryOperation(Lattice lattice, SpaceMatrix rotation, SpaceVector translation)
		{
			Lattice = lattice;
			Rotation = rotation;
			Translation = translation;
		}

		public Position Transform(Position position)
		{
			return new Position(Lattice, Transform(Lattice.Decompose(position).Coordinates));
			//return new Position(Lattice, Rotation * Lattice.Decompose(position).Coordinates + Translation);
		}
		
		public SpaceVector Transform(SpaceVector position)
		{
			return Rotation * position + Translation;
		}

		public Lattice Lattice
		{
			get;
			private set;
		}

		/// <summary>
		/// Symmetry rotation matrix. Relative to the basis of the structure.
		/// </summary>
		public SpaceMatrix Rotation
		{
			get;
			private set;
		}

		/// <summary>
		/// Symmetry translation matrix. Relative to the basis of the structure.
		/// </summary>
		public SpaceVector Translation
		{
			get;
			private set;
		}
	}
}
